<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>订单列表</title>
    <link rel="stylesheet" href="css/font-awesome.min.css"/>
    <link rel="stylesheet" href="css/font-awesome-ie7.min.css"/>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link href="css/jquery.datetimepicker.css" rel="stylesheet">
    <link rel="stylesheet" href="css/admin.css"/>

    <link rel="stylesheet" type="text/css" href="css/paging.css">

    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <![endif]-->
    <!--[if lt IE 10]>
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/jquery-placeholder/2.0.8/jquery.placeholder.min.js"></script>
    <![endif]-->
    <style>
        .stateMemo {
            white-space: pre-wrap !important;
            width: 170px !important;
            display: block;
            height: auto;

        }
    </style>
</head>
<body>
<div id="gray_bg"></div>
<!-- 删除订单结束 -->
<!-- header start -->
<div id="header" class="header">

</div>
<!-- header end -->
<!-- usercenter start -->
<div class="usercotent">
    <div id="center-left"></div>
    <div class="usercotentr floatr">
        <div class="user-tit" style="margin-bottom:10px">
            <h3>订单列表</h3>
        </div>
        <div class="usercotent-con">
            <div class="btnList">
                <div class="col-md-2" style="width: 170px !important;">
                    <strong class="ordertext">从：</strong>
                    <input id="datetimepicker_searchbegin" class="inputStory" type="text"
                           style="width:110px !important;height: 34px !important;">
                </div>
                <div class="col-md-2" style="width: 170px !important;">
                    <strong class="ordertext">到：</strong>
                    <input id="datetimepicker_searchend" class="inputStory" type="text"
                           style="width:110px !important;height: 34px !important;">
                </div>
                <div class="col-md-2" style="width: 140px !important;">
                    <input id="search_keyvalue" class="inputStory" type="text"
                           style="width:140px !important;height: 34px !important;" placeholder="关键字">
                </div>
                <div class="col-md-2" style="width: 150px !important;">
                    <button style="width: 150px; height: 35px;float: left" id="order_search" type="button"
                            class="btn btn-success">搜索
                    </button>
                </div>
                <!--<div class="col-md-2" style="width: 170px !important;margin-left: 20px;">-->
                <!--<button style="width: 150px; height: 35px;float: left" id="export" type="button"-->
                <!--class="btn btn-primary">导 出-->
                <!--</button>-->
                <!--</div>-->
            </div>


            <div class="down">
                <table id="testMyGrid" class="table table-bordered table-hover"></table>
            </div>
            <!-- page start -->
            <nav class="totalpage floatr">
                <span>总共</span><strong id="totalpage"></strong><span>条</span>
                <div id="pageTool" style="margin-top:20px;"></div>
            </nav>
            <div class="clear"></div>
            <!-- page end -->
        </div>

    </div>
    <div class="clear"></div>
</div>

<!-- usercenter end -->

<!-- footer start -->
<div class="footer">
    <div class="bot">
        <p style="padding-top: 10px; text-align: center">Copyright (C) 都能印 2014-2016, all Rights Reserved |
            豫ICP备14024464号-1 | 增值电信业务经营许可证：豫B2-20150019</p>
        <p class="authentication" style="padding-bottom: 10px; padding-top: 10px;">
            <img src="img/footer1.png" alt="">
            <img src="img/footer2.png" alt="">
            <img src="img/footer3.png" alt="">
            <img src="img/footer4.png" alt="">
            <img src="img/footer5.png" alt="">
        </p>
    </div>
</div>
<!-- footer end -->
<script src="js/jquery.min-1-11-3.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/widget/myDataGrid.js"></script>
<script src="js/jquery.datetimepicker.full.js"></script>
<script src="js/widget/admin.js"></script>
<script type="text/javascript" src="js/query.js"></script>
<script type="text/javascript" src="js/paging.js"></script>
<script type="text/javascript">
    //开始
    $(function () {
        // body...
        $('#datetimepicker_searchbegin').datetimepicker({
            lang: 'ch',
            formatDate: 'Y-m-d',
            format: 'Y-m-d',
            timepicker: false,
            //minDate:'none', // yesterday is minimum date
            timepicker: false
        })
    })

    $(function () {
        // body...
        $('#datetimepicker_searchend').datetimepicker({
            lang: 'ch',
            formatDate: 'Y-m-d',
            format: 'Y-m-d',
            timepicker: false,
            //minDate:'none', // yesterday is minimum date
            timepicker: false
        })
    })

    $(function () {
        initSideAccMenu("订单管理", "订单列表");
        var usertype = loginUserType;
        if(usertype == 999){
            //表格数据
            $("#testMyGrid").grid({
                id: "testMyGrid",
                pageTotalId: "totalpage",
                pageToolId: "pageTool",
                url: "apis/order/getpartnerorderpagelist",
                method: "post",
                columns: [
                    {field: 'idOrder', title: '#', conmethod: 'getRecordIndex', calcfield: '', kind: '', region: 0},
//                {field: 'ordertype', title: '订单类型', conmethod: 'getOrdertype', calcfield: '', kind: '', region: 0},
                    {field: 'partnerName', title: '合伙人企业名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'productName', title: '产品名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'orderCode', title: '订单编号', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    //{field: 'productname', title: '业务类型', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'orderStatus', title: '订单状态', conmethod: 'getOrderStatus', calcfield: '', kind: '', region: 0},
                    {field: 'orderMoney', title: '订单金额', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'productItemName', title: '订单描述', conmethod: 'getOrderDes', calcfield: '', kind: '', region: 1},
                    {field: 'customerName', title: '联系人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'customerWxNickName', title: '微信名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'customerPhone', title: '联系电话', conmethod: 'getStrPhone', calcfield: '', kind: '', region: 1},
                    {field: 'createTime', title: '下单时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
                    {field: 'managerName', title: '受理人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'manageTime', title: '受理时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
                    {field: 'remark', title: '订单备注', conmethod: 'getRemark', calcfield: '', kind: '', region: 1}
                ],
                pagesize: 10
            });
        }else{
            //表格数据
            $("#testMyGrid").grid({
                id: "testMyGrid",
                pageTotalId: "totalpage",
                pageToolId: "pageTool",
                url: "apis/order/getpartnerorderpagelist",
                method: "post",
                columns: [
                    {field: 'idOrder', title: '#', conmethod: 'getRecordIndex', calcfield: '', kind: '', region: 0},
//                {field: 'ordertype', title: '订单类型', conmethod: 'getOrdertype', calcfield: '', kind: '', region: 0},
                    {field: 'productName', title: '产品名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'orderCode', title: '订单编号', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    //{field: 'productname', title: '业务类型', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'orderStatus', title: '订单状态', conmethod: 'getOrderStatus', calcfield: '', kind: '', region: 0},
                    {field: 'orderMoney', title: '订单金额', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'productItemName', title: '订单描述', conmethod: 'getOrderDes', calcfield: '', kind: '', region: 1},
                    {field: 'customerName', title: '联系人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'customerWxNickName', title: '微信名称', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'customerPhone', title: '联系电话', conmethod: 'getStrPhone', calcfield: '', kind: '', region: 1},
                    {field: 'createTime', title: '下单时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
                    {field: 'managerName', title: '受理人', conmethod: 'getNullStr', calcfield: '', kind: '', region: 0},
                    {field: 'manageTime', title: '受理时间', conmethod: 'getNullDateTime', calcfield: '', kind: '', region: 0},
                    {field: 'remark', title: '订单备注', conmethod: 'getRemark', calcfield: '', kind: '', region: 1}
                ],
                pagesize: 10
            });
        }
        //search
        $("#order_search").click(function () {
            var data = getSearchData();
            if ($("#search_keyvalue").val() == null) {
                alert("请输入关键字进行查询");
                return;
            }
            $("#testMyGrid").grid("search", data);
        })
        function getSearchData() {
            var begintime = $.trim($("#datetimepicker_searchbegin").val());
            var endtime = $.trim($("#datetimepicker_searchend").val());
            var keyword = $.trim($("#search_keyvalue").val());
            if ((begintime == "") && (endtime == "") && (keyword == "")) {
                var data = null;
            } else {
                if ((begintime != "") && (endtime != "") && (keyword != "")) {
                    var data = {
                        "beginDate": begintime + " 00:00:00",
                        "endDate": endtime + " 23:59:59",
                        "keyWord": keyword
                    }
                } else if ((begintime == "") && (endtime == "") && (keyword != "")) {
                    var data = {
                        "keyWord": keyword
                    }
                } else if ((begintime == "") && (endtime != "") && (keyword != "")) {
                    var data = {
                        "keyWord": keyword
                    }
                } else if ((begintime != "") && (endtime == "") && (keyword != "")) {
                    var data = {
                        "keyWord": keyword
                    }
                } else if ((begintime != "") && (endtime != "") && (keyword == "")) {
                    var data = {
                        "beginDate": begintime + " 00:00:00",
                        "endDate": endtime + " 23:59:59"
                    }
                } else {
                    var data = null;
                }
            }
            return data;
        }
    })

    //注释手机号码
    function getStrPhone() {
        var ts = arguments[0] || "";
        var order = arguments[1];
        var shtml = "";
//        if (order.orderStatus <= 0) {
        if (order.customerPhone) {
            var mphone = order.customerPhone.substr(0, 3) + '****' + order.customerPhone.substr(7);
        } else {
            var mphone = ""
        }
//        } else {
//            var mphone = order.customerPhone.substr(0, 3) + '****' + order.customerPhone.substr(7);
//        }

        shtml += "<span>" + mphone + "</span>";
        return shtml;
    }
//    订单描述
    function getOrderDes() {
        var order = arguments[1];
        var shtml = "";
        if(order.productItemName == null || order.productItemName == ""){
            shtml = ""
        }else if(order.productItemName.length > 10){
            shtml = "<span class='stateMemo'>"+order.productItemName+"</span>"
        }
        return shtml;
    }
//    订单备注
    function getRemark() {
        var order = arguments[1];
        var shtml = "";
        if(order.remark == null || order.remark == ""){
            shtml = ""
        }else{
            shtml = "<span class='stateMemo'>"+order.remark+"</span>"
        }
        return shtml;
    }
</script>
</body>
</html>